<template>
    <div class="user">
      <el-table
    :data="list"
      style="width: 100%"
      max-height="100%">
      <el-table-column
        fixed
        label="操作"
        width="260">
        <template slot-scope="scope">
          <!-- 查看详情 -->
          <userDetail :userForm="scope.row" />
          <!-- 编辑用户信息 -->
          <userDetail :userEdit="scope.row" />
          <el-button
            @click.native.prevent="deleteRow(scope.row,scope.$index)"
            type="text"
            size="small">
            重置密码
          </el-button>
          <el-button
            @click.native.prevent="handleDisable(scope.row,scope.$index)"
            :disabled="isDisable"
            type="text"
            size="small">
            禁用
          </el-button>
          <el-button
            @click.native.prevent="deleteRow(scope.$index)"
            type="text"
            size="small">
            岗位分配
          </el-button>
        </template>
      </el-table-column>
      <el-table-column
        prop="username"
        label="用户名"
        width="200">
      </el-table-column>
      <el-table-column
        prop="realName"
        label="真实姓名"
        width="120">
      </el-table-column>
      <el-table-column
        prop="deptname"
        label="部门名称"
        width="150">
      </el-table-column>
      <el-table-column
        prop="phoneNumber"
        label="手机号"
        width="200">
      </el-table-column>
      <el-table-column
        prop="mail"
        label="邮箱"
        width="200">
      </el-table-column>

    </el-table>
    </div>
  </template>

<script>
import { management } from '@/api/setting/userManagement'
import userDetail from './components/userDetail.vue'
export default {
  data() {
    return {
      list: [],
      // 操作按钮是否禁用
      isDisable: false,
    }
  },
  components: {
    userDetail,
  },
  created() {
    // 组件初始渲染时发送网络请求
    const request = async() => {
      try {
        const res = await management()
        res.data.data.forEach(item => {
          this.list.push(item)
        })
      } catch (error) {
        console.log(error)
      }
    }
    request()
  },
  methods: {
    deleteRow(index, row) {
      console.log(12)
    },
    handleDisable(row) {
      if (row) {
        this.isDisable = true
      } else {
        this.isDisable = false
      }
    },
  },
}
</script>
